package com.aier.admin.service.impl;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.aier.admin.common.AdminExcelUtil;
import com.aier.admin.service.IAdminICService;
import com.aier.common.common.Constant;
import com.aier.common.dao.ICommonDAO;
import com.aier.entrance.common.EntranceICFinalData;

@Component("adminICService")
public class AdminICServiceImpl_J implements IAdminICService {

    @Resource(name = "commonDao")
    private ICommonDAO commonDao;

    public void setCommonDao(ICommonDAO commonDao) {
        this.commonDao = commonDao;
    }

    @Override
    public int insertICWrite(List<String[]> list, int type) {
        if (null == list) {
            return -1;
        }
        switch (type) {
            case AdminExcelUtil.TYPE_DEFAULT:
                for (String[] ts : list) {
                    commonDao
                            .update("insert into ic_card(ichead,icbody,icfoot,ictype,icstate,icisn,icdate) value(?,?,?,?,?,?,?)",
                                    new Object[] {
                                        ts[0],
                                        ts[1],
                                        ts[2],
                                        EntranceICFinalData.IC_TYPE_DEFAULT,
                                        EntranceICFinalData.IC_STATE_SYS_NOT_ACTIVE,
                                        ts[Constant.num_3],
                                        new Timestamp(new Date().getTime()) });
                }
                return 1;
            default:
                return 0;
        }
    }
}
